package com.sharon.sharon_note.base.exception;

import com.sharon.sharon_note.base.response.JsonResult;
import com.sharon.sharon_note.base.response.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public JsonResult doHandleException(Exception ex) {
        String msg = ex.getMessage();
        log.debug(msg);
        return new JsonResult(StatusCode.UNKNOWN_ERROR, msg);
    }
}
